package com.platform.manager.action.system;

import com.opensymphony.xwork2.ActionSupport;
import com.platform.domain.TbSysCode;
import com.platform.service.DictService;
import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: wangyanginfo
 * Date: 12-8-22
 * Time: 上午10:27
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/system")
@Service("dictAction")
public class DictAction extends ActionSupport {

    private static final Logger logger = Logger.getLogger(DictAction.class);

    @Resource
    private DictService dictService;

    private List<TbSysCode> tbSysCodeList;

    public List<TbSysCode> getTbSysCodeList() {
        return tbSysCodeList;
    }

    public void setTbSysCodeList(List<TbSysCode> tbSysCodeList) {
        this.tbSysCodeList = tbSysCodeList;
    }

    @Action(value = "queryCodeList", results = {@Result(name = "success", location = "/index.vm")})
    public String queryCodeList() {
        try {
            tbSysCodeList = dictService.queryCodes(null);
            logger.info(tbSysCodeList.size());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return SUCCESS;
    }

    @Action(value = "queryCodes", results = {@Result(name = "success", location = "/system/code/ftl/code_list.ftl")})
    public String queryCodes() {
        return SUCCESS;
    }
}
